﻿using IntelligentAgriculture.Contracts.Dto.Output.EarTagOutput;
using IntelligentAgriculture.Contracts.Dto.Output.ManageOutput;
using IntelligentAgriculture.Contracts.Dto.Output.PageOutput;
using IntelligentAgriculture.Contracts.Interface.EarTagService;
using IntelligentAgriculture.Contracts.Interface.IManagements;
using IntelligentAgriculture.Services.Management;
using IntelligentAgriculture.WebAPI.Application.Command.EarTageCommand;
using IntelligentAgriculture.WebAPI.Application.Command.ManageCommand;
using MediatR;

namespace IntelligentAgriculture.WebAPI.Application.CommandHandler.ColumnManageCommandJamdler
{
    public class EarTageShowCommandHandler : IRequestHandler<EarTageShowCommand, Results<PagesOutput<EarTageShowsOutPut>>>
    {
        private readonly IEarTageService _iearTageService;

        public EarTageShowCommandHandler(IEarTageService _iearTageServices)
        {
            _iearTageService = _iearTageServices;
        }
        /// <summary>
        /// 提供耳标的显示、查询和分页功能
        /// </summary>
        /// <param name="request">包含显示、查询和分页所需的请求参数</param>
        /// <param name="cancellationToken">用于取消操作的令牌</param>
        /// <returns>返回执行耳标显示、查询和分页操作的结果</returns>
        public async Task<Results<PagesOutput<EarTageShowsOutPut>>> Handle(EarTageShowCommand request, CancellationToken cancellationToken)
        {
            var list = await _iearTageService.GetShow(request.Eitag);
            var results = Results<PagesOutput<EarTageShowsOutPut>>.DataResult(list);
            return results;
        }
    }
}
